<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>${SYSTEM_NAME}</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/style/admin.css" media="all">
	<style type="text/css">
		.layui-form-item .layui-input-inline {
		    width: 300px;
		}
	</style>
</head>
<body>
<div class="layui-fluid" style="background-color: #fff;">
		<form class="layui-form" action="" style="width:100%" method="post" name="basicform">
			<input type="text" name="id" style="display: none;" autocomplete = "off" value="${systemID.id }"/>
		  	<input type="text" id="oldAppId" style="display: none;" autocomplete = "off" value="${systemID.appId }"/>
		  <div class="layui-form-item">
		    <label class="layui-form-label layui-form-required">系统名称</label>
		    <div class="layui-input-inline">
		      <input type="text" name="name" lay-verify="required" placeholder="请输入系统名称" class="layui-input" autocomplete="off" value="${systemID.name }">
		    </div>
		    <div class="layui-form-mid layui-word-aux">系统名称不能为空</div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label layui-form-required">appID</label>
		    <div class="layui-input-inline">
		      <input type="text" name="appId" lay-verify="only" placeholder="请输入小程序appID" class="layui-input" autocomplete="off" value="${systemID.appId }">
		    </div>
		    <div class="layui-form-mid layui-word-aux">小程序appID不能为空</div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label layui-form-required">appSecret</label>
		    <div class="layui-input-inline">
		      <input type="text" name="appSecret" lay-verify="appSecret" placeholder="请输入小程序appSecret" class="layui-input" autocomplete="off" value="${systemID.appSecret }">
		    </div>
		    <div class="layui-form-mid layui-word-aux">小程序appSecret不能为空</div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">系统描述</label>
		    <div class="layui-input-inline">
		      <input type="text" name="desp" class="layui-input" value="${systemID.desp }" placeholder="请输入系统描述">
		    </div>
		  </div>
		  
		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
		      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		      <button type="button" class="layui-btn layui-btn-normal" onclick="closed()">关闭</button>
		    </div>
		  </div>
		</form>
  </div>
<script src="${pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${FILE_VERSION}"></script>
<script>
//JavaScript代码区域
layui.config({
	base: getContextPath() + '/static/layuiadmin/' //静态资源所在路径
}).extend({
	index: 'lib/index' //主入口模块
}).use(['form'], function() {
	var form = layui.form;
	form.verify({
		only: function(value, item){ //value：表单的值、item：表单的DOM对象
			
		if(value == "" || value == "null"){
		      return 'appID不能为空';
	    }
		
	    if($("#oldAppId").val() == null || $("#oldAppId").val() == "" || $("#oldAppId").val() != value){
	    	var dataObj = "";
	    	$.ajax({
	            url: getContextPath() + "/sys/paramSystemID/add/checkId",
	            type: "post",
	            async: false,
	            data: {
	                "appId":value
	            },
	            dataType: "json",
	            success: function (json) {
	            	dataObj=json
	            }
	        });
	    	if(dataObj.success == false){
	    		return dataObj.msg;
	    	}
	    }
	  },
	  "appSecret": function(value, item){ //value：表单的值、item：表单的DOM对象
			
			if(value == "" || value == "null"){
			      return 'appSecret不能为空';
		    }
			if(value.length!=32){
			      return 'appSecret是长度为32的字符串，请检查输入是否有误';
		    }
		  }
	});
	form.on('submit(sub)', function(data){
		$ajax({
			url: "/sys/paramSystemID/add/save",
			data: data.field,
	        succCallback: function (json) {
				if(json.code == 0){
	        		parent.reload();
            		var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
            		parent.layer.close(index);//关闭弹出的子页面窗口
            		parent.layer.msg(json.msg);
            	}
	        }
		});
		return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
	});
});

function closed(){
	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
	parent.layer.close(index);//关闭弹出的子页面窗口
}

</script>
</body>
</html>